package co.com.smart.eagle.client.view.impl.smarttextbutton;

import com.google.gwt.cell.client.ButtonCellBase;
import com.google.gwt.cell.client.TextButtonCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.uibinder.client.UiConstructor;
import com.google.gwt.widget.client.TextButton;

public class SmartTextButton extends TextButton{

	public interface MyAppearance extends ButtonCellBase.DefaultAppearance.Resources {
		  @Override
		  @Source(value = {ButtonCellBase.DefaultAppearance.Style.DEFAULT_CSS, "textButton.css"})
		  StyleButton buttonCellBaseStyle();
		  
		  public interface StyleButton extends ButtonCellBase.DefaultAppearance.Style{
			  
		  }
	}
	
	@UiConstructor
	public SmartTextButton(String text){
		super(new TextButtonCell.DefaultAppearance((ButtonCellBase.DefaultAppearance.Resources)GWT.create(MyAppearance.class)), text);
	}
	
	@Override
	public HandlerRegistration addClickHandler(final ClickHandler handler) {		
		return super.addClickHandler(new ClickHandler() {			
			@Override
			public void onClick(ClickEvent event) {
				if(isEnabled())
				{
					handler.onClick(event);
				}
			}
		});	
	}
	
}
